<template>
    <el-dialog
  title="提示"
  :visible.sync="dialogVisible"
  width="30%"
  :before-close="resetForm">
  <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-form-item label="姓名" prop="workerName">
                    <el-input v-model="ruleForm.workerName"></el-input>
                </el-form-item>
                <el-form-item label="所属部门" prop="deptName">
                    <el-select v-model="ruleForm.deptName" placeholder="请选择">
                      <el-option
                        v-for="item in deptList"
                        :key="item.deptName"
                        :label="item.deptName"
                        :value="item.deptName">
                      </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="用户名" prop="username">
                    <el-input v-model="ruleForm.username"></el-input>
                </el-form-item>
                <el-form-item label="联系方式" prop="workerPhone">
                    <el-input v-model="ruleForm.workerPhone"></el-input>
                </el-form-item>
                <el-form-item label="性别" prop="gender">
                    <el-radio-group v-model="ruleForm.gender">
                        <el-radio label="男"></el-radio>
                        <el-radio label="女"></el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="证件照" prop="imageUrl">
                    <el-input v-model="ruleForm.imageUrl"></el-input>
                </el-form-item>
                <div class="btns">
                    <el-button @click="resetForm" class="btn" size="small">取消</el-button>
                    <el-button type="primary" @click="submitForm('ruleForm')" class="btn" size="small">确定</el-button>
                </div>
            </el-form>
</el-dialog>
</template>
<script>
import {getDept}  from '@/api'

export default {
    props:{
        ruleForm:{
            type:Object,
            default:()=>{}
        },
        isShowModal:{
            type:Boolean,
            default:()=>false
        }
    },

    computed:{
            dialogVisible:{
                get: function () { return this.isShowModal } ,
                set: function (val) { }
            }
        },
        
    data() {
      return {
        rules: {},
        deptList:[]
      };
    },
    mounted(){
        getDept(1).then(res=>{
        if(res.code==200){
          this.deptList=res.data
        }
      })
        },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.$emit('modalSure',this.ruleForm)
          } else {
            return false;
          }
        });
      },
      resetForm() {
        this.dialogVisible=false
        this.$emit('modalCancel')
      }
    }
  }
</script>
<style lang="less" scoped>
.register {
    width: 100%;
    height: 100%;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.8);
    .register-box{
        margin: 100px auto;
        width: 600px;
        position: relative;
        .register-title{
            width: 100%;
            color: blueviolet;
            font-weight: 700;
            text-align: center;
            padding: 10px 0;
            font-size: 22px;
        }
        .btns{
            width: 100%;
            // height: 50px;
            display: flex;
            justify-content: space-around;
            .btn{
                width: 100px;
            }
        }
        .tips{
            position: absolute;
            right: 10px;
            top: 10px;
        }
    }
}
</style>